<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <#assign base=request.contextPath  />
    <link rel="stylesheet" href="${base}/js/layui/css/layui.css?t=1534970980648" media="all">
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script src="${base}/js/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script src="${base}/js/jquery.min.js"></script>

    <style type="text/css">
		form{
		  padding:20px;
		}
		.layui-btn-radius{
                 border-radius: 5px;
                }
		</style>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
          <div class="layui-inline">
                   <label class="layui-form-label"><a style="color:red">*</a>&nbsp;房间</label>
                      <div class="layui-input-block">
                      <select name="city" lay-verify="required" class="isNull" lay-search="" id="home">
                       <option value=""></option>
                    </select>
                  </div>
                </div>
        <div class="layui-inline">
                    <label class="layui-form-label"><a style="color:red">*</a>&nbsp;产康项目</label>
                              <div class="layui-input-block">
                              <select name="city" lay-verify="required" lay-search="" class="isNull" id="project">
                               <option value=""></option>
                            </select>
                          </div>
                        </div>
                         <div class="layui-inline">
                                            <label class="layui-form-label"><a style="color:red">*</a>&nbsp;评价</label>
                                                     <div id="pingfen"></div>
                                                </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-radius" lay-submit lay-filter="formDemo" type="button" onclick="sub()" style="background-color: #0092EF;">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
            </div>
        </div>

</form>

<script>
    var bas1="${base}"
    var puding_data=findProject()
    for(var i=0;i<puding_data.length;i++){
        $("#project").append(
                '<option value="'+puding_data[i].id+'">'+puding_data[i].project+'</option>'
        )
    }
    var homeData=getDataByDicCode(bas1,"allHome");
    for(var j=0;j<homeData.length;j++){
        $("#home").append(
                '<option value="'+homeData[j].id+'">'+homeData[j].name+'</option>'
        )
    }
layui.use(['form', 'layedit', 'laydate','layer','rate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
var rate = layui.rate;
 rate.render({
     elem: '#pingfen',
     theme: '#FE0000'
   })




});
function findProject(){
    var resultdata;
    $.ajax({
        type:"POST",
        url:"${base}/evaluate/findAllProject",
        async:false,
        success : function(data){
            resultdata=data;
        }
    });
    return resultdata;
}
    function sub(){
 if(!isNull()){
 return ;
 }

        var star=0;
        $(".layui-rate").each(function(){
            $(this).find('li').find('i').each(function() {
                if($(this).attr("class")=='layui-icon layui-icon-rate-solid'){
                    star+=1;
                }
            });
        });

        $.ajax({
            type:"POST",
            url:"${base}/evaluate/addEvaluate",
            data:{"star":star,"relationId":$("#home").val(),"projectId":$("#project").val()},
            async:false,
            success : function(data){
               layer.msg(data)
                parent.initChar(null);
                setTimeout(function(){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                },200)
            }
        });
    }
</script>
</body>
</html>
